<?php

namespace App\Models;



use Illuminate\Http\Exceptions\HttpResponseException;

class CzOrder extends ApiBaseModel
{

    protected $table = 'cz_order';
    protected $fillable = [
        "pay_id",
        'order_sn',
        'product_name',
        'mobile',
        'face_value',
        'cost',
        'price',
        'area_name',
        'province_id',
        'city_id',
        'order_status',
        'isp',
        'biz_type',
        'hf_type',
        'is_refund',
        'product_id',
        'spec_id',
        'channel_id',
        'timeout',
        'is_loop',
        'create_by',
        'update_by',
        'finished_at',
        'submit_from',
        'submit_order_count',
        'is_auto',
        'user_order_sn',
        'batch_order_sn',
        'is_stop',
        'msg',
        'callback_url',
        'skip_hook',
        'pay_status',
        'refund_status',
        "openid",
        "appid"
    ];
    protected $casts = [
        'order_status' => 'string',
        'refund_status' => 'string',
        'pay_status' => 'string',
        'isp' => 'string',
        'biz_type' => 'string',
    ];


    // public function registerGlobalScopes($builder)
    // {
    //     foreach ($this->getGlobalScopes() as $identifier => $scope) {
    //         $builder->withGlobalScope($identifier, $scope);
    //     }

    //     $builder->where('pay_status', '=', 1);

    //     return $builder;
    // }
    public function user()
    {
        return $this->belongsTo(SysUser::class, 'create_by', 'id');
    }
    public function pay()
    {
        return $this->belongsTo(Payment::class, 'pay_id', 'id');
    }
    public function channel()
    {
        return $this->belongsTo(CzChannel::class, 'channel_id', 'id');
    }
}
